from math import sqrt


def add(x, y):
    return x + y


def sub(x, y):
    return x - y


def mul(x, y):
    return x * y


def div(x, y):
    return x / y


def divd(x, y):
    return x // y


def mod(x, y):
    return x % y


def power(x):
    return x ** 2


def spu(x):
    return sqrt(x)


if __name__ == "__main__":
    print('计算器V1.0')
    fun_str = "\n输入'q'并按下Enter键退出"
    fun_str += "\n请选择功能：\n1：加法\t 2：减法\t 3：乘法\t 4：除法\n5：整除\t 6：取余\t 7：乘方\t 8：开方\n>>>: "

    active = True
    while active:
        fun1 = input(fun_str)

        if fun1 == 'q':
            active = False
        else:
            fun1 = int(fun1)
            if fun1 == 1:
                x = input("请输入第一个数：")
                y = input("请输入第二个数：")
                x = float(x)
                y = float(y)
                print("%0.3f 加 %0.3f 等于 %0.3f" % (x, y, add(x, y)))
            elif fun1 == 2:
                x = input("请输入第一个数：")
                y = input("请输入第二个数：")
                x = float(x)
                y = float(y)
                print("%0.3f 减 %0.3f 等于 %0.3f" % (x, y, sub(x, y)))
            elif fun1 == 3:
                x = input("请输入第一个数：")
                y = input("请输入第二个数：")
                x = float(x)
                y = float(y)
                print("%0.3f 乘 %0.3f 等于 %0.3f" % (x, y, mul(x, y)))
            elif fun1 == 4:
                x = input("请输入第一个数：")
                y = input("请输入第二个数：")
                x = float(x)
                y = float(y)
                print("%0.3f 除 %0.3f 等于 %0.3f" % (x, y, div(x, y)))
            elif fun1 == 5:
                x = input("请输入第一个数：")
                y = input("请输入第二个数：")
                x = float(x)
                y = float(y)
                print("%0.3f 整除 %0.3f 等于 %0.3f" % (x, y, divd(x, y)))
            elif fun1 == 6:
                x = input("请输入第一个数：")
                y = input("请输入第二个数：")
                x = float(x)
                y = float(y)
                print("%0.3f 对 %0.3f 取余等于 %0.3f" % (x, y, mod(x, y)))
            elif fun1 == 7:
                x = input("请输入一个数：")
                x = float(x)
                print("%0.3f 的乘方等于 %0.3f" % (x, power(x)))
            elif fun1 == 8:
                x = input("请输入一个数：")
                x = float(x)
                print("%0.3f 的开方等于 %0.3f" % (x, spu(x)))






